//
//  CornerVC.m
//  UILbrary
//
//  Created by Apple on 2022/4/19.
//  Copyright © 2022 mac. All rights reserved.
//

#import "CornerVC.h"
#import "UIView+Tool.h"

@interface CornerVC ()

@end

@implementation CornerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor grayColor];
    [self p_configCorderView_5];
    //p_configCorderView_2
    //p_configCorderView_4
}


- (void)p_configCorderView
{
    UIView *view = [UIView new];
    view.frame = CGRectMake(100, 100, 100, 50);
    view.backgroundColor = [UIColor redColor];
    [self.view addSubview:view];
    
    UIBezierPath *path = [UIBezierPath bezierPath];
    CGFloat radius = 10.0;
    [path addArcWithCenter:CGPointMake(100, 0) radius:radius startAngle:M_PI_2 endAngle:M_PI_2*2  clockwise:YES];
    [path fill];
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    shapeLayer.path = path.CGPath;
    
    view.layer.mask = shapeLayer;

}


- (void)p_configCorderView_1
{
    UIView *view = [UIView new];
    view.frame = CGRectMake(10, 100, 300, 200);
    view.backgroundColor = [UIColor redColor];
    [self.view addSubview:view];
    
    CGRect smallRect = CGRectMake(-50, -50, 100, 100);
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:view.bounds];
    [path appendPath:[[UIBezierPath bezierPathWithRoundedRect:smallRect cornerRadius:50] bezierPathByReversingPath]];
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    shapeLayer.path = path.CGPath;
    
    view.layer.mask = shapeLayer;
}

- (void)p_configCorderView_2
{
    UIView *view = [UIView new];
    view.frame = CGRectMake(10, 100, 300, 200);
    view.backgroundColor = [UIColor redColor];
    [self.view addSubview:view];
    [view addReverseCorner:UIViewCornerTypeLeftBottom radius:10];
}


- (void)p_configCorderView_3
{
    UIView *view = [UIView new];
    view.frame = CGRectMake(10, 100, 300, 200);
    view.backgroundColor = [UIColor redColor];
    [self.view addSubview:view];
    [view addReverseCorner:UIViewCornerTypeLeftBottom radius:10];

    UIView *view_1 = [UIView new];
    view_1.frame = CGRectMake(0, 0, 300, 200);
    view_1.backgroundColor = [UIColor orangeColor];
    [view addSubview:view_1];
    
}

- (void)p_configCorderView_4
{
    UIView *view = [UIView new];
    view.frame = CGRectMake(10, 100, 300, 200);
    view.backgroundColor = [UIColor redColor];
    [self.view addSubview:view];
    [view addReverseCorner:UIViewCornerTypeLeftBottom radius:10];
    [view addReverseCorner:UIViewCornerTypeLeftTop radius:10];
    [view addReverseCorner:UIViewCornerTypeRightTop radius:10];
    [view addReverseCorner:UIViewCornerTypeRightBottom radius:10];

}

- (void)p_configCorderView_5
{
    UIView *view = [UIView new];
    view.frame = CGRectMake(10, 100, 300, 200);
    view.backgroundColor = [UIColor redColor];
    [self.view addSubview:view];
    [view addReverseCornerRadius:10];

}


@end
